import axios from 'axios'
import apiUrls from 'common/api-urls'
import { contentTypeWww } from 'common/axio-decorate'

export function getUser(params) {
  return axios.get(apiUrls.getUser, {
    params: {
      ...params
    }
  })
}

export function addUser(data) {
  return axios.post(apiUrls.addUser, {
    ...data
  })
}

export function updateUser(data) {
  return axios.patch(apiUrls.updateUser, {
    ...data
  })
}

export function deleteUser(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.delete(`${apiUrls.deleteUser}?ids=${data.ids}`)
}

export function getUserInfo(data) {
  data = JSON.parse(JSON.stringify(data))
  return axios.get(`${apiUrls.getUserInfo}/${data.id}`, {
    params: data
  }, {
    headers: { 'Content-Type': contentTypeWww }
  })
}
